/* Context Engine Panel 样式 - VS Code 科技风格 */

:root {
    --vscode-font-family: var(--vscode-font-family);
    --primary-color: #0078d4;
    --primary-hover: #106ebe;
    --success-color: #107c10;
    --warning-color: #ffb900;
    --danger-color: #d13438;
    --accent-color: #005a9e;
    --tech-blue: #00bcf2;
    --tech-purple: #8b5cf6;
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
    --spacing-xxl: 32px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.35s ease;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--vscode-font-family);
    font-size: var(--vscode-font-size);
    color: var(--vscode-foreground);
    background: linear-gradient(135deg,
        var(--vscode-sideBar-background) 0%,
        color-mix(in srgb, var(--vscode-sideBar-background) 95%, var(--tech-blue) 5%) 100%);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    padding: var(--spacing-lg);
    max-width: 100%;
    position: relative;
}

/* 头部样式 - 科技风格 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--vscode-sideBar-background) 90%, var(--primary-color) 10%) 0%,
        color-mix(in srgb, var(--vscode-sideBar-background) 95%, var(--tech-purple) 5%) 100%);
    border-radius: var(--border-radius-lg);
    border: 1px solid color-mix(in srgb, var(--vscode-sideBar-border) 70%, var(--primary-color) 30%);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color), var(--tech-blue), var(--tech-purple));
    opacity: 0.8;
}

.header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--vscode-sideBarTitle-foreground);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.5px;
}

.author-info {
    display: flex;
    align-items: center;
    font-size: 11px;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: color-mix(in srgb, var(--vscode-badge-background) 80%, transparent 20%);
    border-radius: var(--border-radius);
    border: 1px solid var(--vscode-badge-background);
}

.author-text {
    color: var(--vscode-badge-foreground);
    font-weight: 500;
    /* text-transform: uppercase; */
    letter-spacing: 0.5px;
}

/* 区域样式 - 现代化卡片设计 */
.section {
    margin-bottom: var(--spacing-xl);
    background: color-mix(in srgb, var(--vscode-sideBar-background) 98%, var(--vscode-foreground) 2%);
    border-radius: var(--border-radius-lg);
    border: 1px solid color-mix(in srgb, var(--vscode-sideBar-border) 60%, transparent 40%);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

/* 移除悬停浮动效果 */

.section h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--vscode-sideBarSectionHeader-foreground);
    background: linear-gradient(135deg,
        var(--vscode-sideBarSectionHeader-background) 0%,
        color-mix(in srgb, var(--vscode-sideBarSectionHeader-background) 90%, var(--primary-color) 10%) 100%);
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid color-mix(in srgb, var(--vscode-sideBar-border) 50%, transparent 50%);
    position: relative;
}

.section h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: var(--spacing-lg);
    right: var(--spacing-lg);
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    opacity: 0.5;
}

.section .section-content {
    padding: var(--spacing-lg);
}

/* 主要区域样式 - 更大的空间 */
.main-section {
    min-height: 500px;
}

.main-section .section-content {
    padding: var(--spacing-xl);
}

.main-section .input-container {
    position: relative;
    margin-bottom: var(--spacing-xl);
}

/* 编辑器信息样式 */
.editor-info {
    background-color: var(--vscode-input-background);
    border: 1px solid var(--vscode-input-border);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
}

.info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.info-item:last-child {
    margin-bottom: 0;
}

.label {
    font-weight: 500;
    color: var(--vscode-descriptionForeground);
}

.value {
    color: var(--vscode-foreground);
    font-family: var(--vscode-editor-font-family);
}

/* 范围按钮样式 */
.range-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.range-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: var(--spacing-md);
    background-color: var(--vscode-button-secondaryBackground);
    color: var(--vscode-button-secondaryForeground);
    border: 1px solid var(--vscode-button-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.range-btn:hover:not(:disabled) {
    background-color: var(--vscode-button-secondaryHoverBackground);
    transform: translateY(-1px);
}

.range-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.range-btn.selected {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-icon {
    font-size: 16px;
    margin-bottom: var(--spacing-xs);
}

.btn-text {
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
}

.btn-desc {
    font-size: 12px;
    opacity: 0.8;
}

.selected-range {
    background-color: var(--vscode-inputValidation-infoBackground);
    border: 1px solid var(--vscode-inputValidation-infoBorder);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
    font-size: 12px;
}

.range-label {
    font-weight: 500;
    margin-right: var(--spacing-sm);
}

/* 代码预览样式 */
.code-preview {
    background-color: var(--vscode-editor-background);
    border: 1px solid var(--vscode-input-border);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    font-family: var(--vscode-editor-font-family);
    font-size: var(--vscode-editor-font-size);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-placeholder {
    color: var(--vscode-descriptionForeground);
    font-style: italic;
    text-align: center;
    padding: var(--spacing-lg);
}

/* 智能提示输入样式 - 科技风格 */
.input-container {
    position: relative;
    margin-bottom: var(--spacing-lg);
}

.prompt-input {
    width: 100%;
    height: calc(100% - 80px); /* 减去标签和按钮的空间 */
    min-height: 200px;
    margin-top: 10px;
    padding: var(--spacing-lg) var(--spacing-lg) 60px var(--spacing-lg); /* 正常的顶部padding，下方为按钮预留空间 */
    background: linear-gradient(135deg,
        var(--vscode-input-background) 0%,
        color-mix(in srgb, var(--vscode-input-background) 98%, var(--tech-blue) 2%) 100%);
    color: var(--vscode-input-foreground);
    border: 2px solid color-mix(in srgb, var(--vscode-input-border) 70%, var(--primary-color) 30%);
    border-radius: var(--border-radius-lg);
    font-family: var(--vscode-editor-font-family);
    font-size: var(--vscode-font-size);
    resize: vertical;
    line-height: 1.6;
    transition: all var(--transition-normal);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
}

.prompt-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.1),
        0 0 0 3px color-mix(in srgb, var(--primary-color) 20%, transparent 80%),
        var(--shadow-md);
    transform: translateY(-1px);
}

.prompt-input::placeholder {
    color: color-mix(in srgb, var(--vscode-input-placeholderForeground) 70%, transparent 30%);
    font-style: italic;
}

/* 引用标签样式 - 位于输入框内部顶部 */
.reference-tags-inside {
    position: absolute;
    top: 8px;
    left: 12px;
    right: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    z-index: 5;
    pointer-events: none; /* 允许点击穿透到输入框 */
    max-height: 60px; /* 限制标签区域高度 */
    overflow: hidden; /* 超出部分隐藏 */
}

.reference-tags-inside .reference-tag {
    pointer-events: auto; /* 标签本身可以点击 */
}

.reference-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    background: #6c6c6c;
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 400;
    cursor: pointer;
    margin-right: 4px;
    margin-bottom: 2px;
    transition: background-color 0.1s ease;
}

.reference-tag:hover {
    background: #5a5a5a;
}

.reference-tag-icon {
    font-size: 10px;
    opacity: 0.9;
}

.reference-tag-text {
    font-family: var(--vscode-editor-font-family);
    white-space: nowrap;
}

.reference-tag-close {
    margin-left: 3px;
    color: white;
    font-size: 12px;
    font-weight: normal;
    cursor: pointer;
    opacity: 0.7;
    line-height: 1;
}

.reference-tag-close:hover {
    opacity: 1;
}

/* 文件引用标签 */
.reference-tag.file-ref .reference-tag-icon::before {
    content: '📄';
}

/* 符号引用标签 */
.reference-tag.symbol-ref .reference-tag-icon::before {
    content: '#';
}

/* 自动完成下拉框样式 - 悬浮定位 */
.autocomplete-dropdown {
    position: fixed; /* 使用 fixed 定位，相对于视口 */
    background-color: var(--vscode-dropdown-background);
    border: 1px solid var(--vscode-dropdown-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-height: 250px;
    min-width: 200px;
    max-width: 400px;
    overflow-y: auto;
    z-index: 1000;
    /* 位置将通过 JavaScript 动态设置 */
}

.autocomplete-item {
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    border-bottom: 1px solid var(--vscode-dropdown-border);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background-color: var(--vscode-list-hoverBackground);
}

.autocomplete-item.selected {
    background-color: var(--vscode-list-activeSelectionBackground);
    color: var(--vscode-list-activeSelectionForeground);
}

.autocomplete-icon {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.autocomplete-name {
    font-weight: 500;
}

.autocomplete-detail {
    font-size: 12px;
    color: var(--vscode-descriptionForeground);
    margin-left: auto;
}

/* 当前打开文件的特殊样式 */
.autocomplete-item.active-file {
    background-color: color-mix(in srgb, var(--vscode-list-activeSelectionBackground) 20%, transparent 80%);
    border-left: 3px solid var(--vscode-list-activeSelectionBackground);
}

.autocomplete-item.active-file:hover {
    background-color: color-mix(in srgb, var(--vscode-list-activeSelectionBackground) 30%, transparent 70%);
}

.active-file-indicator {
    color: var(--vscode-list-activeSelectionBackground);
    font-size: 8px;
    margin-left: 4px;
    margin-right: 4px;
}

/* 引用标签样式 */
.reference-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    min-height: 20px;
}

.reference-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: var(--primary-color);
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.reference-tag.file-ref {
    background-image: linear-gradient(to top, #1e3c72 0%, #1e3c72 1%, #2a5298 100%);
}

.reference-tag.symbol-ref {
    background-color: #ffc107;
    color: black;
}

.reference-tag-remove {
    cursor: pointer;
    font-weight: bold;
    margin-left: var(--spacing-xs);
    opacity: 0.7;
}

.reference-tag-remove:hover {
    opacity: 1;
}



/* 建议按钮样式已删除 */

/* 操作按钮样式 - 科技风格主按钮 */
.action-buttons {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.generate-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) var(--spacing-xl);
    background: linear-gradient(135deg,
        var(--success-color) 0%,
        color-mix(in srgb, var(--success-color) 80%, var(--tech-blue) 20%) 100%);
    color: white;
    border: 2px solid var(--success-color);
    border-radius: var(--border-radius-lg);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.generate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left var(--transition-slow);
}

.generate-btn:hover {
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--success-color) 90%, white 10%) 0%,
        color-mix(in srgb, var(--success-color) 70%, var(--tech-blue) 30%) 100%);
    border-color: color-mix(in srgb, var(--success-color) 80%, white 20%);
}

.generate-btn:hover::before {
    left: 100%;
}

.generate-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.generate-btn:disabled {
    background: var(--vscode-button-secondaryBackground);
    color: var(--vscode-button-secondaryForeground);
    border-color: var(--vscode-button-secondaryBackground);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.generate-btn .btn-icon {
    font-size: 16px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* 悬浮生成按钮样式 - Cursor 风格 */
.generate-btn-floating {
    position: absolute;
    bottom: var(--spacing-md);
    right: var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: linear-gradient(135deg,
        var(--success-color) 0%,
        color-mix(in srgb, var(--success-color) 80%, var(--tech-blue) 20%) 100%);
    color: white;
    border: 2px solid var(--success-color);
    border-radius: var(--border-radius-lg);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
    z-index: 10;
    min-width: 80px;
    height: 36px;
}

.generate-btn-floating:hover {
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--success-color) 90%, white 10%) 0%,
        color-mix(in srgb, var(--success-color) 70%, var(--tech-blue) 30%) 100%);
    border-color: color-mix(in srgb, var(--success-color) 80%, white 20%);
    box-shadow: var(--shadow-lg);
}

.generate-btn-floating:active {
    transform: scale(0.95);
}

.generate-btn-floating:disabled {
    background: var(--vscode-button-secondaryBackground);
    color: var(--vscode-button-secondaryForeground);
    border-color: var(--vscode-button-secondaryBackground);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

.generate-btn-floating .btn-icon {
    font-size: 14px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.generate-btn-floating .btn-text {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* 历史记录标题样式 - 继承主标题样式 */
.header.history-header {
    margin-bottom: 0; /* 移除底部间距，因为它在 section 内部 */
}

.header.history-header h2 {
    font-size: 16px; /* 稍微小一点，但保持主标题的风格 */
}

.collapse-btn {
    background: color-mix(in srgb, var(--vscode-button-secondaryBackground) 80%, transparent 20%);
    border: 1px solid color-mix(in srgb, var(--vscode-button-border) 60%, transparent 40%);
    color: var(--vscode-foreground);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collapse-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
    box-shadow: var(--shadow-sm);
}

.collapse-icon {
    font-size: 12px;
    transition: transform var(--transition-normal);
    font-weight: bold;
}

.collapse-btn.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.history-content {
    transition: all var(--transition-slow);
    overflow: hidden;
}

.history-content.collapsed {
    max-height: 0;
    margin-bottom: 0;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--vscode-scrollbarSlider-background) transparent;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--vscode-scrollbarSlider-background);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--vscode-scrollbarSlider-hoverBackground);
}

.history-placeholder {
    text-align: center;
    color: var(--vscode-descriptionForeground);
    font-style: italic;
    padding: var(--spacing-xxl);
    background: color-mix(in srgb, var(--vscode-sideBar-background) 98%, var(--vscode-foreground) 2%);
    border-radius: var(--border-radius-lg);
    border: 2px dashed color-mix(in srgb, var(--vscode-sideBar-border) 50%, transparent 50%);
}

.history-item {
    padding: var(--spacing-xs) var(--spacing-sm);
    margin-bottom: 2px;
    background: var(--vscode-list-hoverBackground);
    border: 1px solid color-mix(in srgb, var(--vscode-list-hoverBackground) 80%, var(--primary-color) 20%);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.history-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--primary-color), var(--tech-blue));
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.history-item:hover {
    background: linear-gradient(135deg,
        var(--vscode-list-activeSelectionBackground) 0%,
        color-mix(in srgb, var(--vscode-list-activeSelectionBackground) 95%, var(--primary-color) 5%) 100%);
    color: var(--vscode-list-activeSelectionForeground);
}

.history-item:hover::before {
    opacity: 1;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.history-item-title {
    font-weight: 500;
    font-size: 10px;
    color: var(--vscode-foreground);
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-title::before {
    content: '📄';
    font-size: 8px;
    flex-shrink: 0;
}

.history-item-time {
    font-size: 8px;
    color: var(--vscode-descriptionForeground);
    background: color-mix(in srgb, var(--vscode-badge-background) 60%, transparent 40%);
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 400;
    flex-shrink: 0;
}

.history-item-preview {
    font-size: 9px;
    color: var(--vscode-descriptionForeground);
    line-height: 1.2;
    max-height: 18px;
    overflow: hidden;
    position: relative;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
}

.history-item-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 30px;
    height: 15px;
    background: linear-gradient(90deg, transparent, var(--vscode-list-hoverBackground));
}

/* 消息提示样式 */
.message-container {
    position: fixed;
    top: var(--spacing-md);
    right: var(--spacing-md);
    z-index: 1000;
}

.message {
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-sm);
    animation: slideIn 0.3s ease;
    max-width: 300px;
    word-wrap: break-word;
}

.message.success {
    background-color: var(--success-color);
    color: white;
}

.message.error {
    background-color: var(--danger-color);
    color: white;
}

.message.warning {
    background-color: var(--warning-color);
    color: black;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 300px) {
    .container {
        padding: var(--spacing-sm);
    }
    
    .range-buttons {
        gap: var(--spacing-xs);
    }
    
 
}
